#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   风控人工审核数据导入mysql.py    
@Contact :   fengfeng.qiu@amh-group.com

@Modify Time      @Author    
------------      -------    
2022/5/20 9:27   qiufengfeng      
'''
import pandas as pd

file_name = r"D:\工作相关内容\公司项目\禁限运危化品货源\data\人工审核结果明细\风控审核结果.csv"
df = pd.read_csv(file_name,sep='')
def change_contraband_tag(item):
    """将reason里面确定为违禁品的，改一下备注，改成统一的备注"""
    if "近期承运违规货源信息" in item["reason"]:
        return "确认是违禁品"
    elif "近期发布违规货源信息" in item["reason"]:
        return "确认是违禁品"
    elif '词错误，转文本' in item['reason']:
        return "关键词错误,语音转文本出错"
    elif '词错误，是转文本' in item['reason']:
        return "关键词错误,语音转文本出错"
    elif "无法确定货物为危化品" in item["reason"]:
        return "词正确,无法确定货物为危化品"
    elif "无法确定是否为危化品" in item["reason"]:
        return "词正确,无法确定货物为危化品"
    elif "词正确，用户仅聊到" in item["reason"]:
        return "词正确,用户仅聊到"
    elif "听不懂" in item["reason"]:
        return "语音或者文本,听不懂"
    elif "未找到违禁词" in item["reason"]:
        return "未找到违禁词"
    elif "词正确，用户仅仅聊到" in item["reason"]:
        return "词正确,用户仅聊到"
    elif "水性的" in item["reason"]:
        return "词正确,无法确定货物为危化品"
    elif "货主打错字，实际是化肥" in item["reason"]:
        return "关键词错误,语音转文本出错"
    elif "非危险品货源" in item["reason"]:
        return "词正确,无法确定货物为危化品"
    elif "非违禁品货源" in item["reason"]:
        return "词正确,无法确定货物为危化品"
    else:
        return item["reason"]
df.dropna(subset=["reason"],inplace=True)
df.dropna(subset=["calltext"],inplace=True)
df['reason'] = df.apply(change_contraband_tag,axis=1)
df_save = df[df['reason']=="确认是违禁品"]
df_save.to_csv("确认是违禁品.csv")
print(df['reason'].value_counts())